package com.ejiaoyi.api.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ejiaoyi.api.mapper.ApiLogMapper;
import com.ejiaoyi.api.service.IApiLogService;
import com.ejiaoyi.api.support.datasource.DataSourceKey;
import com.ejiaoyi.common.entity.ApiLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@DS(DataSourceKey.LOG)
public class ApiLogServiceImpl implements IApiLogService {

    @Autowired
    private ApiLogMapper apiLogMapper;

    @Override
    public Integer addLog(ApiLog apiLog) {
        int result = apiLogMapper.insert(apiLog);

        return result == 1 ? apiLog.getId() : -1;
    }

    @Override
    public void updateLog(ApiLog apiLog) {
        apiLogMapper.updateById(apiLog);
    }
}
